<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改草稿')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-xiaoxi-edit" th:object="${xiaoxi}">
            <input name="xiaoxiid" th:field="*{xiaoxiid}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">邮件标题：</label>
                <div class="col-sm-8">
                    <textarea style="height: 120px" name="biaoti" class="form-control" required>[[*{biaoti}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">邮件内容：</label>
                <div class="col-sm-8">
                    <textarea style="height: 400px" name="neirong" class="form-control" required>[[*{neirong}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">接收人：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="jieshouren" onclick="selectJieshourenTree()" id="jieshourennames" type="text"
                               class="form-control"  th:field="*{jieshouren}" required>
                        <input name="jieshourenid" id="jieshourenids" class="form-control" style="display:none"  th:field="*{jieshourenid}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/xiaoxi";
        $("#form-xiaoxi-edit").validate({
            focusCleanup: true
        });
        function doSubmit(index, layero) {
            var iframeWin = $(layero).find("iframe")[0].contentWindow //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method()
            var rows = iframeWin.getSelections();
            var jieshourenids=new Array();
            var jieshourennames=new Array();
            if(rows.length>0){
                for (var i = 0; i < rows.length; i++) {
                    jieshourenids.push(rows[i]["userId"]);
                    jieshourennames.push(rows[i]["userName"]);
                }
                $("#jieshourenids").val(jieshourenids);
                $("#jieshourennames").val(jieshourennames);
            }
            $.modal.close(index);
        }
        /* 选择接收人 */
        function selectJieshourenTree() {
            $.modal.open("选择接收人", "/system/xiaoxi/JieshourenTree", 1400 ,800,doSubmit);
        }
        function submit(status) {
            if ($.validate.form()) {
                var formdata = $('#form-xiaoxi-edit').serialize()
                formdata += "&zhuangtai=" + status;
                $.operate.save(prefix + "/edit", formdata);
            }
        }
    </script>
</body>
</html>